package com.yunxin.admin.system.api.core.enums;

import com.yunxin.admin.system.infra.common.constant.SecurityConstants;
import com.yunxin.common.result.Result;
import com.yunxin.core.application.command.utils.EnumOptionCommand;
import com.yunxin.core.application.dto.areas.AreasTwoLevelDTO;
import com.yunxin.core.application.dto.utils.EnumOptionDTO;
import com.yunxin.core.application.service.AreasQueryService;
import com.yunxin.core.application.service.EnumOptionQueryService;
import com.yunxin.core.utils.infra.common.enums.EnumOptionTypeEnum;
import com.yunxin.core.utils.infra.common.enums.EnumSourceTypeEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zero°
 * @since 2023-05-29
 */
@Tag(name = "99.枚举选项")
@Slf4j
@RestController
@RequestMapping("/core/v1/enum/option")
@RequiredArgsConstructor
public class EnumOptionController {


    private final EnumOptionQueryService enumOptionQueryService;

    private final AreasQueryService areasQueryService;


    @Operation(summary = "获取区域", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/getAreas")
    public Result<List<AreasTwoLevelDTO>> getAreas() {
        List<AreasTwoLevelDTO> result = areasQueryService.listTwoLevelArea();
        return Result.success(result);
    }

    @Operation(summary = "获取所有城市", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/getAllCity")
    public Result<List<String>> getAllCity() {
        return Result.success(areasQueryService.getAllCity());
    }

    @Operation(summary = "公积金情况枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/accumulationFundLevel")
    public Result<List<EnumOptionDTO>> accumulationFundLevel() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.ACCUMULATION_FUND_LEVEL);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "信用卡枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/creditCardQuota")
    public Result<List<EnumOptionDTO>> creditCardQuota() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.CREDIT_CARD);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "教育情况枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/educationLevel")
    public Result<List<EnumOptionDTO>> educationLevel() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.EDUCATION_LEVEL);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "房产情况枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/houseLevel")
    public Result<List<EnumOptionDTO>> houseLevel() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.HOUSE_LEVEL);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result =  enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "保险枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/lifeInsurePeriod")
    public Result<List<EnumOptionDTO>> lifeInsurePeriod() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.INSURE);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "微粒贷额度枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/microLoanQuota")
    public Result<List<EnumOptionDTO>> microLoanQuota() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.MICRO_LOAN_QUOTA);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "芝麻信用分额度枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/sesameSeedQuota")
    public Result<List<EnumOptionDTO>> sesameSeedQuota() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.SESAME_SEED_QUOTA);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "社保情况枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/socialSecurityLevel")
    public Result<List<EnumOptionDTO>> socialSecurityLevel() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.SOCIAL_SECURITY_LEVEL);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "车产情况枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/vehicleLevel")
    public Result<List<EnumOptionDTO>> vehicleLevel() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.VEHICLE_LEVEL);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "职业枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/occupation")
    public Result<List<EnumOptionDTO>> occupation() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.OCCUPATION);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }


    @Operation(summary = "职业收入枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/occupationIncome")
    public Result<List<EnumOptionDTO>> occupationIncome() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.OCCUPATION_INCOME);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "京东白条额度枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/jdBtQuota")
    public Result<List<EnumOptionDTO>> jdBtQuota() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.JD_BT_QUOTA);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "蚂蚁花呗额度枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/antCreditPayQuota")
    public Result<List<EnumOptionDTO>> antCreditPayQuota() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.ANT_CREDIT_PAY_QUOTA);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "性别枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/sex")
    public Result<List<EnumOptionDTO>> sex() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.SEX);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

    @Operation(summary = "逾期枚举", security = {@SecurityRequirement(name = SecurityConstants.TOKEN_KEY)})
    @GetMapping("/beOverdue")
    public Result<List<EnumOptionDTO>> beOverdue() {
        EnumOptionCommand command = new EnumOptionCommand();
        command.setEnumOptionType(EnumOptionTypeEnum.BE_OVERDUE);
        command.setSourceType(EnumSourceTypeEnum.ADMIN);
        List<EnumOptionDTO> result = enumOptionQueryService.listEnumOption(command);
        return Result.success(result);
    }

}
